home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d13
/
pcrnov89.arc
/
PP.ARC
/
PP.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-03-21
|
12KB
|
567 lines
DEFINT A-Z
ON ERROR GOTO TESTERROR
START:
COLOR 7, 1: CLS
' -- Initialize string arrays --
NE = 12
DIM ACTION$(6 TO 17), CONTROL$(6 TO 17)
DIM BT$(3 TO 5), CT$(3 TO 5), EM$(1 TO 5)
DIM RADDRESS$(NE, 2 TO 5)
DIM ADDRESS$(NE, 11 TO 15), ATTN$(NE)
DIM MENU$(3), MESSAGE$(5)
' -- Setup string variables --
NUM$ = " A B C D E F G H I J K L"
BLK$ = STRING$(50, 32)
H$ = STRING$(50, 205)
BLK2$ = STRING$(27, 32)
B$ = CHR$(194) + STRING$(22, 196) + CHR$(182)
A$ = STRING$(9, 32) + "ACTION" + STRING$(10, 32)
BT$(3) = CHR$(201) + LEFT$(H$, 25) + CHR$(187)
BT$(4) = CHR$(186) + A$ + CHR$(186)
BT$(5) = CHR$(199) + STRING$(2, 196) + B$
BL0$ = CHR$(207) + LEFT$(H$, 22) + CHR$(188)
BL1$ = CHR$(200) + LEFT$(H$, 2) + BL0$
BL2$ = CHR$(179) + LEFT$(BLK$, 22) + CHR$(186)
CT1$ = LEFT$(BLK$, 20) + CHR$(186)
CT0$ = LEFT$(BLK$, 16) + "CONTROL STRING" + CT1$
CT$(3) = CHR$(201) + H$ + CHR$(187)
CT$(4) = CHR$(186) + CT0$
CT$(5) = CHR$(199) + STRING$(50, 196) + CHR$(182)
CT4$ = CHR$(186) + BLK$ + CHR$(186)
CT5$ = CHR$(200) + H$ + CHR$(188)
MENU$(1) = CHR$(201) + LEFT$(H$, 36) + CHR$(187)
MENU$(2) = CHR$(186) + LEFT$(BLK$, 36) + CHR$(186)
MENU$(3) = CHR$(200) + LEFT$(H$, 36) + CHR$(188)
RET$ = "<" + STRING$(2, 196) + CHR$(217)
TE$ = " to EXIT "
MESSAGE$(1) = "<S>end <A>ssign <E>nvelope <Q>uit"
MESSAGE$(2) = " <A>ction <C>ontrol <E>xit "
MESSAGE$(3) = RET$ + " to SEND <Esc> to EXIT "
MESSAGE$(4) = " Type Action String " + RET$ + TE$
MESSAGE$(5) = "Type Control String " + RET$ + TE$
UK$ = CHR$(0) + CHR$(72): DK$ = CHR$(0) + CHR$(80)
LK$ = CHR$(0) + CHR$(75): RK$ = CHR$(0) + CHR$(77)
HOME$ = CHR$(0) + CHR$(71): END$ = CHR$(0) + CHR$(79)
PGUP$ = CHR$(0) + CHR$(73): PGDN$ = CHR$(0) + CHR$(81)
PRNT$ = CHR$(0) + CHR$(59)
EM$(1) = " <F1> Print "
EM$(2) = "<PG UP> Next "
EM$(3) = "<PG DN> Previous "
EM$(4) = "<TAB> Advance "
EM$(5) = "<ESC> Exit"
FOR J = 6 TO 17
CST = LEN(CONTROL$(J))
AST = LEN(ACTION$(J))
CONTROL$(J) = CONTROL$(J) + STRING$(50 - CST, 32)
ACTION$(J) = ACTION$(J) + STRING$(22 - AST, 32)
NEXT
FOR JJ = 1 TO NE
FOR J = 2 TO 5
RADDRESS$(JJ, J) = STRING$(29, 32)
NEXT
FOR J = 11 TO 15
ADDRESS$(JJ, J) = STRING$(40, 32)
NEXT
FOR HJ = 1 TO 12
ATTN$(HJ) = STRING$(41, 32)
NEXT
NEXT
' -- Load data file from disk --
9999 OPEN "PP.DAT" FOR INPUT AS #1
FOR J = 6 TO 17
INPUT #1, CONTROL$(J)
INPUT #1, ACTION$(J)
NEXT
FOR JJ = 1 TO NE
FOR J = 2 TO 5
INPUT #1, RADDRESS$(JJ, J)
NEXT
FOR J = 11 TO 15
INPUT #1, ADDRESS$(JJ, J)
NEXT
INPUT #1, ATTN$(JJ)
NEXT
CLOSE 1
GOSUB GETPIC
'-- Display message headers --
GETKEYS:
DO
X$ = INKEY$
X$ = UCASE$(X$)
SELECT CASE X$
CASE "S"
GOSUB SEND
ACTION = 0: GOSUB GATHER
MESSAGE = 1
GOSUB MENUBAR
CASE "A"
GOSUB ASSIGN
CASE "Q"
GOSUB SAVEFILE: CLS : END
CASE "E"
COLOR 15, 1: CLS
GOSUB PRINTENV
CLS : GOSUB GETPIC: JJ = 1
CASE ELSE
END SELECT
LOOP
' -- Assign action/control string --
ASSIGN:
MESSAGE = 2
GOSUB MESSAGEBAR
DO
X$ = INKEY$
X$ = UCASE$(X$)
SELECT CASE X$
CASE "A"
MESSAGE = 4: GOSUB MESSAGEBAR
ACTION = 1: GOSUB BEXIT: RETURN
CASE "C"
MESSAGE = 5: GOSUB MESSAGEBAR
ACTION = 2: GOSUB BEXIT: RETURN
CASE "E"
MESSAGE = 1: GOSUB MENUBAR
CASE ELSE
END SELECT
LOOP
' -- Turn on edit mode / get strings --
BEXIT:
LEDIT = 1
GOSUB GETSET
GOSUB GETSIDE
GOSUB GATHER
MESSAGE = 1
GOSUB MESSAGEBAR
LEDIT = 0
RETURN
' -- Send control string to printer --
SEND:
MESSAGE = 3
GOSUB MENUBAR
ACTION = 1
LEDIT = 0
ACCEPT = YES
GOSUB GETSET
GOSUB GETSIDE
GOSUB GATHER
IF ACTION = 0 THEN RETURN
J = 0: B$ = ""
C$ = RTRIM$(LTRIM$(CONTROL$(CLNE))) + ","
DO
J = J + 1
IF J > LEN(C$) THEN EXIT DO
A$ = MID$(C$, J, 1)
IF A$ = "#" THEN
LPRINT MID$(C$, 2, LEN(C$) - 2); CHR$(13); CHR$(10)
EXIT DO
END IF
IF A$ = "," OR J = LEN(C$) THEN
LPRINT CHR$(VAL(B$)); : B$ = ""
ELSE
B$ = B$ + A$
END IF
LOOP
RETURN
' -- Move cursor / get info from display --
GETSET:
IF ACTION > 2 THEN ACTION = 1
IF ACTION = 1 THEN
MAXPOS = 26: MINPOS = 5: MAXLNE = 17: MINLNE = 6
END IF
IF ACTION = 2 THEN
MAXPOS = 79: MINPOS = 30: MAXLNE = 17: MINLNE = 6
END IF
CPOS = MINPOS: CLNE = MINLNE
RETURN
GETSIDE:
LOCATE MINLNE, MINPOS
GOSUB GATHER
COLOR 0, 7: LOCATE MINLNE, MINPOS
GOSUB GATHER
MOVECUR:
DO
X$ = INKEY$
SELECT CASE (X$)
CASE ""
IF LEDIT THEN GOSUB FLASH
CASE CHR$(13)
ACCEPT = YES: GOSUB GATHER: RETURN
CASE CHR$(27)
ACCEPT = NO: ACTION = 0: RETURN
CASE UK$
IF CLNE > MINLNE THEN
COLOR 7, 0: GOSUB GATHER
CLNE = CLNE - 1
COLOR 0, 7: GOSUB GATHER
END IF
CASE DK$
IF CLNE < MAXLNE THEN
COLOR 7, 0: GOSUB GATHER
CLNE = CLNE + 1
COLOR 0, 7: GOSUB GATHER
END IF
CASE LK$
IF LEDIT THEN
IF CPOS > MINPOS THEN CPOS = CPOS - 1
END IF
CASE RK$
IF LEDIT THEN
IF CPOS < MAXPOS THEN
CPOS = CPOS + 1: GOTO MOVECUR
END IF
END IF
CASE CHR$(8)
IF CPOS > MINPOS THEN
LOCATE CLNE, CPOS: PRINT " ";
CPOS = CPOS - 1
END IF
CASE HOME$
LOCATE CLNE, MINPOS: CPOS = MINPOS
CASE END$
LOCATE CLNE, MAXPOS: CPOS = MAXPOS
CASE CHR$(32) TO CHR$(127)
IF LEDIT THEN
LOCATE CLNE, CPOS: PRINT X$;
IF CPOS < MAXPOS THEN CPOS = CPOS + 1
END IF
CASE ELSE
END SELECT
IF ACTION = 1 AND LEDIT = 0 THEN
X$ = UCASE$(X$)
IF X$ > CHR$(64) AND X$ < CHR$(77) THEN
COLOR 7, 0: GOSUB GATHER
CLNE = ASC(X$) - 59
COLOR 0, 7: GOSUB GATHER
END IF
END IF
LOOP
' -- Grab string from display --
GATHER:
GATHER$ = ""
FOR NPOS = MINPOS TO MAXPOS
GATHER$ = GATHER$ + CHR$(SCREEN(CLNE, NPOS))
NEXT
LOCATE CLNE, MINPOS
IF ACTION = 0 OR REXIT THEN COLOR 7, 0
IF ACTION = 1 THEN ACTION$(CLNE) = GATHER$
IF ACTION = 2 THEN CONTROL$(CLNE) = GATHER$
IF ACTION = 3 THEN RADDRESS$(JJ, CLNE) = GATHER$
IF ACTION = 4 THEN ADDRESS$(JJ, CLNE) = GATHER$
IF ACTION = 5 THEN ATTN$(JJ) = GATHER$
PRINT GATHER$; : RETURN
' -- Flash cursor --
FLASH:
FL$ = CHR$(SCREEN(CLNE, CPOS))
COLOR 7, 0: LOCATE CLNE, CPOS: PRINT CHR$(219);
GOSUB PAUSE
COLOR 7, 0: LOCATE CLNE, CPOS: PRINT FL$;
GOSUB PAUSE
RETURN
' -- Pause timer --
PAUSE:
T! = TIMER: WHILE T! = TIMER: WEND: RETURN
'-- Print title and form --
ACTION:
COLOR 7, 4
PRINT BLK2$; "PC RESOURCE PRINTER PRIMER"; BLK2$
COLOR 0, 7
FOR LNE = 3 TO 5
LOCATE LNE, 1: PRINT BT$(LNE);
NEXT
SPOS = 1
FOR LNE = 6 TO 17
LOCATE LNE, 1:
PRINT CHR$(186); MID$(NUM$, SPOS, 2); BL2$;
SPOS = SPOS + 2
NEXT
LOCATE LNE, 1: PRINT BL1$;
COLOR 7, 1
RETURN
CONTROL:
COLOR 0, 7
FOR LNE = 3 TO 5
LOCATE LNE, 29: PRINT CT$(LNE);
NEXT
FOR LNE = 6 TO 17
LOCATE LNE, 29: PRINT CT4$
NEXT
LOCATE 18, 29: PRINT CT5$;
RETURN
MENUBAR:
FOR LNE = 20 TO 22
LOCATE LNE, 20: PRINT MENU$(LNE - 19);
NEXT
MESSAGEBAR:
LOCATE 21, 21: PRINT MESSAGE$(MESSAGE);
RETURN
' -- Save data file to disk --
SAVEFILE:
OPEN "PP.DAT" FOR OUTPUT AS #1
FOR J = 6 TO 17
WRITE #1, CONTROL$(J)
WRITE #1, ACTION$(J)
NEXT
FOR JJ = 1 TO NE
FOR J = 2 TO 5
WRITE #1, RADDRESS$(JJ, J)
NEXT
FOR J = 11 TO 15
WRITE #1, ADDRESS$(JJ, J)
NEXT
WRITE #1, ATTN$(JJ)
NEXT
CLOSE 1
RETURN
' -- Print envelope template --
MAKENVELOPE:
COLOR 0, 7
LOCATE 1, 1
PRINT CHR$(218); STRING$(78, 196) + CHR$(191);
FOR LNES = 2 TO 23
LOCATE LNES, 1
PRINT CHR$(179); TAB(80); CHR$(179);
NEXT
LOCATE 24, 1
PRINT CHR$(192) + STRING$(78, 196) + CHR$(217);
RETURN
' -- Envelope data entry --
PRINTENV:
LOCATE 25, 1
FOR J = 1 TO 5
PRINT EM$(J);
NEXT
GOSUB MAKENVELOPE: COLOR 7, 0
GOSUB GETENVELOPE: ACTION = 3
GOSUB ACTPARM
DO
X$ = INKEY$
SELECT CASE (X$)
CASE ""
GOSUB FLASH
CASE CHR$(27)
RETURN
CASE CHR$(13)
CPOS = MINPOS
COLOR 7, 0: GOSUB GATHER: COLOR 0, 7
IF CLNE < MAXLNE THEN
CLNE = CLNE + 1
ELSE
CLNE = MINLNE
END IF
CASE CHR$(9)
REXIT = 1: GOSUB GATHER: REXIT = 0
ACTION = ACTION + 1: GOSUB ACTPARM
CASE CHR$(8)
IF CPOS > MINPOS THEN CPOS = CPOS - 1
CASE HOME$
LOCATE CLNE, MINPOS: CPOS = MINPOS
CASE END$
LOCATE CLNE, MAXPOS: CPOS = MAXPOS
CASE UK$
IF CLNE > MINLNE THEN
GOSUB GATHER: CLNE = CLNE - 1
END IF
CASE DK$
IF CLNE < MAXLNE THEN
GOSUB GATHER: CLNE = CLNE + 1
END IF
CASE LK$
IF CPOS > MINPOS THEN CPOS = CPOS - 1
CASE RK$
IF CPOS < MAXPOS THEN CPOS = CPOS + 1
CASE CHR$(32) TO CHR$(127)
LOCATE CLNE, CPOS: COLOR 7, 0: PRINT X$;
IF CPOS < MAXPOS THEN CPOS = CPOS + 1
CASE PRNT$
GOSUB SENDPRINT
CASE PGUP$
JJ = JJ + 1: GOSUB GETENVELOPE
CASE PGDN$
JJ = JJ - 1: GOSUB GETENVELOPE
CASE ELSE
END SELECT
LOOP
' -- Assign action code --
ACTPARM:
IF ACTION > 5 THEN ACTION = 3
IF ACTION = 3 THEN
MAXPOS = 32: MINPOS = 4
MAXLNE = 5: MINLNE = 2
END IF
IF ACTION = 4 THEN
MAXPOS = 67: MINPOS = 28
MAXLNE = 15: MINLNE = 11
END IF
IF ACTION = 5 THEN
MAXPOS = 44: MINPOS = 4
MAXLNE = 23: MINLNE = 23
END IF
CPOS = MINPOS: CLNE = MINLNE
RETURN
'-- Reprint the form --
GETPIC:
YES = 1: NO = 0
GOSUB ACTION: GOSUB CONTROL
MESSAGE = 1: GOSUB MENUBAR: COLOR 7, 0
FOR J = 6 TO 17
LOCATE J, 5: PRINT ACTION$(J);
LOCATE J, 30: PRINT CONTROL$(J);
NEXT
RETURN
' -- Print envelope address --
GETENVELOPE:
IF JJ > NE THEN JJ = 1
IF JJ < 1 THEN JJ = NE
LOCATE 2, 67
PRINT "ENVELOPE :"; : PRINT USING "##"; JJ;
FOR J = 2 TO 5
LOCATE J, 4: PRINT RADDRESS$(JJ, J);
NEXT
FOR J = 11 TO 15
LOCATE J, 28: PRINT ADDRESS$(JJ, J);
NEXT
LOCATE 23, 4: PRINT ATTN$(JJ)
RETURN
' --- Send address to printer ----
SENDPRINT:
LPRINT
FOR J = 2 TO 5
LPRINT TAB(5); RADDRESS$(JJ, J)
NEXT
FOR J = 6 TO 10
LPRINT
NEXT
FOR J = 11 TO 15
LPRINT TAB(29); ADDRESS$(JJ, J)
NEXT
FOR J = 16 TO 22
LPRINT
NEXT
LPRINT TAB(5); ATTN$(JJ)
RETURN
' -- Error Handler --
TESTERROR:
IF ERR > 23 AND ERR < 28 OR ERR = 68 THEN
GOSUB ASKERR: RESUME NEXT
END IF
' -- Start a new file --
IF ERL = 9999 THEN
IF ERR = 53 THEN GOSUB SAVEFILE: RESUME 9999
END IF
CLS : PRINT "Error "; ERR; " in line "; ERL;
CLOSE : END
ASKERR:
BEEP: SMESS$ = ""
FOR SAVEMESS = 1 TO 80
SMESS$ = SMESS$ + CHR$(SCREEN(25, SAVEMESS))
NEXT
LOCATE 25, 1
COLOR 7, 1: PRINT STRING$(80, 32);
LOCATE 25, 1
PRINT "Printer not responding";
PRINT "<RETURN> Continue <ESC> Quit";
DO
X$ = INKEY$
SELECT CASE (X$)
CASE CHR$(13)
LOCATE 25, 1: PRINT SMESS$; : RETURN
CASE CHR$(27)
GOSUB SAVEFILE: CLS : END
CASE ELSE
END SELECT
LOOP